package main;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;
import java.util.Vector;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.FlowLayout;

import javax.swing.JOptionPane;
import javax.swing.JToggleButton;
import javax.swing.BoxLayout;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.JLabel;
import net.miginfocom.swing.MigLayout;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import java.awt.Insets;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.JComboBox;

import org.eclipse.swt.widgets.MessageBox;

import com.mysql.jdbc.ResultSetMetaData;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JPasswordField;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JTextArea;

public class LayoutNhanVien extends JFrame {

	private static final long serialVersionUID = -6464587060272247354L;
	private Connection con = null;
	Properties props = new Properties();
	DefaultTableModel model;
	Statement st;
	ResultSet rs;
	private JTable jTable1;
	private JTextField textSearchKH;
	private JTextField textField;
	private JTextField textField_1;
	private JTextField textField_2;
	private JTextField textField_3;
	private JTextField textField_4;
	private JTextField textField_5;
	private JTextField textField_6;
	private JTextField textField_7;
	private JTextField txtMaSo;
	private JTextField txtHoTen;
	private JTextField txtNgaySinh;
	private JTextField txtDiaChi;
	private JTextField txtSoThueBao;
	private JPasswordField passMatKhau;
	private JPasswordField passXacNhan;
	private JComboBox comboGioiTinh;
	private JTextArea txtPhanHoi;
	public JButton btnDangKy,btnSua, btnHuy, btnGuiPhanHoi;
	final Vector vtColumn;
	Vector vtRow;
	final Vector vtData;

	// private DefaultTableModel tableModel = new DefaultTableModel();

	public LayoutNhanVien() throws SQLException {
		vtData = new Vector();
		vtColumn = new Vector();

		vtColumn.add("Mã số");
		vtColumn.add("Họ và tên");
		vtColumn.add("Giới tính");
		vtColumn.add("Ngày sinh");
		vtColumn.add("Địa chỉ");
		vtColumn.add("Số đăng ký");
		// vtData.add(vtColumn);

		try {
			Class.forName("com.mysql.jdbc.Driver");
			props.setProperty("user", "root");
			props.setProperty("password", "");
			props.setProperty("con", "utf8_unicode_ci");
			con = DriverManager.getConnection(
					"jdbc:mysql://localhost:3306/qlsodt", props);
			// Khởi tạo đối tượng Statement
			st = con.createStatement();
			// cho phép gửi câu lệnh sql
			rs = st.executeQuery("select * from nhanvien ");
			if (rs != null) {
				while (rs.next()) {
					vtRow = new Vector();
					vtRow.add(rs.getString("MaNV"));
					vtRow.add(rs.getString("TenNV"));
					vtRow.add(rs.getString("GioiTinhNV"));
					vtRow.add(rs.getString("NgaySinhNV"));
					vtRow.add(rs.getString("DiaChiNV"));
					vtRow.add(rs.getString("SDTNV"));
					vtData.add(vtRow);
				}
			}
			getContentPane().setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5));
			// Taoj table vaf load csdl len jtextfiled
			jTable1 = new JTable();

			// model.fireTableDataChanged();
			jTable1.addMouseListener(new MouseAdapter() {
				@Override
				public void mouseClicked(MouseEvent arg0) {
					model = new DefaultTableModel(vtData, vtColumn);
					int row = jTable1.getSelectedRow();
					txtMaSo.setText(model.getValueAt(row, 0).toString());
					txtHoTen.setText(model.getValueAt(row, 1).toString());
					comboGioiTinh.setSelectedItem(model.getValueAt(row, 2)
							.toString());
					txtNgaySinh.setText(model.getValueAt(row, 3).toString());
					txtDiaChi.setText(model.getValueAt(row, 4).toString());
					txtSoThueBao.setText(model.getValueAt(row, 5).toString());

				}
			});
			// jTable1.setAutoResizeMode( );
			JScrollPane scrollPane = new JScrollPane(jTable1);

			getContentPane().add(scrollPane);
			scrollPane.setAutoscrolls(true);
			scrollPane.setPreferredSize(new Dimension(500, 350));

			// panel.add(jTable1);
			model = new DefaultTableModel(vtData, vtColumn);
			jTable1.setModel(model);
			jTable1.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
			jTable1.getColumnModel().getColumn(1).setPreferredWidth(150);
			jTable1.getColumnModel().getColumn(5).setPreferredWidth(100);
			// panel hiển thị tho
			JPanel panel_TKTT = new JPanel();
			getContentPane().add(panel_TKTT);
			panel_TKTT.setLayout(new BoxLayout(panel_TKTT, BoxLayout.Y_AXIS));

			JPanel panelTimKiem = new JPanel();
			panel_TKTT.add(panelTimKiem, BorderLayout.NORTH);

			JLabel lblMSKhch = new JLabel("Mã số nhân viên");
			panelTimKiem.add(lblMSKhch);

			textSearchKH = new JTextField();
			panelTimKiem.add(textSearchKH);
			textSearchKH.setColumns(20);

			JButton btnNewButton = new JButton("Tìm");
			st = con.createStatement();
			btnNewButton.addActionListener(new ActionListener() {

				public void actionPerformed(ActionEvent e) {

					String sqlfind = "select * from khachhang where MaKH='"
							+ textSearchKH.getText() + "'";
					try {
						st = con.createStatement();
						rs = st.executeQuery(sqlfind);
						// cho phép gửi câu lệnh sql

						// model = new DefaultTableModel(vtData, vtColumn);
						// jTable1.setModel(model(rs.next()));
						jTable1.repaint();

					} catch (SQLException e1) {
						// TODO Auto-generated catch block
						e1.printStackTrace();
					}

				}
			});
			panelTimKiem.add(btnNewButton);

			JPanel panelThongtTin = new JPanel();
			panel_TKTT.add(panelThongtTin);
			panelThongtTin.setPreferredSize(new Dimension(470, 360));
			panelThongtTin.setBackground(Color.LIGHT_GRAY);

			JLabel lblNewLabel = new JLabel("Mã số :");

			txtMaSo = new JTextField();
			txtMaSo.setEditable(false);
			txtMaSo.setColumns(10);

			txtHoTen = new JTextField();
			txtHoTen.setEditable(false);
			txtHoTen.setColumns(10);

			JLabel lblNewLabel_1 = new JLabel("Họ và tên:");

			JLabel lblNewLabel_2 = new JLabel("Giới tính:");
			String[] gt = { "Nam", "Nữ" };
			comboGioiTinh = new JComboBox(gt);

			JLabel lblNewLabel_3 = new JLabel("Ngày sinh:");

			txtNgaySinh = new JTextField();
			txtNgaySinh.setEditable(false);
			txtNgaySinh.setColumns(10);

			JLabel lblNewLabel_4 = new JLabel("Địa chỉ:");

			txtDiaChi = new JTextField();
			txtDiaChi.setEditable(false);
			txtDiaChi.setColumns(10);

			JLabel lblNewLabel_5 = new JLabel("Số điện thoại:");

			txtSoThueBao = new JTextField();
			txtSoThueBao.setEditable(false);
			txtSoThueBao.setColumns(10);

			JLabel lblTnGiCc = new JLabel("Phản hồi:");

			 btnDangKy = new JButton("Thêm");
			btnDangKy.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {

					if (btnDangKy.getText() == "Thêm") {
						ediTrue();
						clear();
						jTable1.setEnabled(false);
						btnDangKy.setText("Xong");
						btnSua.setText("Hủy");
						btnHuy.setEnabled(false);

					} else {
						if (btnDangKy.getText() == "Hủy") {
							btnDangKy.setText("Thêm");
							btnSua.setText("Sửa thông tin");
							btnHuy.setEnabled(true);
							ediFalse();
						} else {

							if (txtMaSo.getText().toString().equals("")
									|| txtHoTen.getText().toString().equals("")
									|| txtNgaySinh.getText().toString()
											.equals("")
									|| passMatKhau.getText().toString()
											.equals("")
									|| txtDiaChi.getText().toString()
											.equals("")
									|| txtSoThueBao.getText().toString()
											.equals("")) {
								JOptionPane.showMessageDialog(
										LayoutNhanVien.this,
										"Vui lòng điền đầy đủ thông tin",
										"Lỗi", JOptionPane.ERROR_MESSAGE);

							} else {
								if (passMatKhau
										.getText()
										.toString()
										.equals(passXacNhan.getText()
												.toString())) {
									String sqlInsertKH = "insert into nhanvien values('"
											+ txtMaSo.getText()
											+ "','"
											+ passMatKhau.getText()
											+ "','"

											+ txtHoTen.getText()
											+ "','"
											+ comboGioiTinh.getSelectedItem()
													.toString()
											+ "','"
											+ txtNgaySinh.getText()
											+ "','"
											+ txtDiaChi.getText()
											+ "','"
											+ txtSoThueBao.getText() + "')";

									Statement st;
									try {
										st = con.createStatement();
										st.execute(sqlInsertKH);
										JOptionPane.showMessageDialog(
												LayoutNhanVien.this,
												"Thêm thành công nhân viên"
														+ txtMaSo.getText()
																.toString());
										model = new DefaultTableModel(vtData,
												vtColumn);
										jTable1.setModel(model);
										jTable1.repaint();
										model.addRow(vtData);
										ediFalse();
										btnDangKy.setText("Thêm");
										btnSua.setText("Sửa thông tin");
										btnHuy.setEnabled(true);
										jTable1.repaint();
										jTable1.validate();
										jTable1.setEnabled(true);
									} catch (SQLException e) {
										// TODO Auto-generated catch block
										e.printStackTrace();
										JOptionPane.showMessageDialog(
												LayoutNhanVien.this,
												"Thêm thất bại");
									}
								} else
									JOptionPane.showMessageDialog(
											LayoutNhanVien.this,
											"Mật khẩu không khớp");
							}

						}
					}
				}
			});

			btnSua = new JButton("Sửa thông tin");
			btnSua.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					if (btnSua.getText() == "Hủy") {
						ediFalse();
						btnSua.setText("Sửa thông tin");
						btnDangKy.setText("Thêm");
						btnHuy.setEnabled(true);
						jTable1.setEnabled(true);
					} else {
						if (btnSua.getText() == "Xong") {
							String sqlUpdateKH = "update nhanvien set TenNV='"
									+ txtHoTen.getText()
									+ "', GioiTinhNV='"
									+ comboGioiTinh.getSelectedItem()
											.toString() + "' , NgaySinhNV='"
									+ txtNgaySinh.getText() + "', DiaChiNV='"
									+ txtDiaChi.getText() + "', SDTNV='"
									+ txtSoThueBao.getText() + "' where MaNV='"
									+ txtMaSo.getText().toString() + "'";
							try {
								st = con.createStatement();
								st.execute(sqlUpdateKH);
								JOptionPane.showMessageDialog(
										LayoutNhanVien.this,
										"Update thành công thông tin nhân viên "
												+ txtMaSo.getText());
								ediFalse();
								btnDangKy.setText("Thêm");
								btnHuy.setEnabled(true);
								btnSua.setText("Sửa thông tin");
								jTable1.repaint();
							} catch (SQLException e1) {
								// TODO Auto-generated catch block
								e1.printStackTrace();
								JOptionPane.showMessageDialog(
										LayoutNhanVien.this, "Update thất bại");
								btnHuy.setEnabled(true);
							}

						} else {
							btnSua.setText("Xong");
							btnDangKy.setText("Hủy");
							ediTrue();
							txtMaSo.setEditable(false);
							passMatKhau.setEditable(false);
							passXacNhan.setEditable(false);
							btnHuy.setEnabled(false);
						}
					}

				}
			});
			btnHuy = new JButton("Xóa");
			btnHuy.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					if (btnHuy.getText() == "Không gửi") {
						btnDangKy.setEnabled(true);
						btnSua.setEnabled(true);
						btnGuiPhanHoi.setText("Gửi phản hồi");
						btnHuy.setText("Xóa");
						txtPhanHoi.setEditable(false);
						txtPhanHoi.setText("");
					} else {
						if (txtMaSo.getText().toString().equals("")) {
							JOptionPane.showMessageDialog(LayoutNhanVien.this,
									"Hãy chọn một mã số!");
						} else {
							String sqldel = "delete from nhanvien where MaNV='"
									+ txtMaSo.getText().toString() + "'";
							try {
								int tb = JOptionPane.showConfirmDialog(null,
										"Xóa nhân viên "
												+ txtMaSo.getText().toString(),
										"Xác nhận xóa",
										JOptionPane.OK_CANCEL_OPTION);
								if (tb == JOptionPane.OK_OPTION) {
									st = con.createStatement();
									st.execute(sqldel);
									JOptionPane.showMessageDialog(
											LayoutNhanVien.this,
											"Xóa thành công nhân viên "
													+ txtMaSo.getText());
									jTable1.repaint();
								} else {

								}

							} catch (SQLException e1) {
								// TODO Auto-generated catch block
								e1.printStackTrace();
								JOptionPane.showMessageDialog(
										LayoutNhanVien.this,
										"Hủy không thành công");
							}
						}
					}

				}
			});

			JLabel lblMtKhu = new JLabel("Mật khẩu:");

			passMatKhau = new JPasswordField();
			passMatKhau.setEditable(false);

			passXacNhan = new JPasswordField();
			passXacNhan.setEditable(false);

			JLabel lblXcNhn = new JLabel("Xác nhận:");

			txtPhanHoi = new JTextArea();
			txtPhanHoi.setEditable(false);

			btnGuiPhanHoi = new JButton("Gửi phản hồi");
			btnGuiPhanHoi.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
			
					if (btnGuiPhanHoi.getText() == "Gửi") {
						if (txtMaSo.getText().toString().equals("")) {
							JOptionPane.showMessageDialog(LayoutNhanVien.this,
									"Chọn nhân viên cần phản hồi");
						} else {
							
							if (txtPhanHoi.getText().toString().equals(""))
								JOptionPane.showMessageDialog(
										LayoutNhanVien.this,
										"Chưa có thông tin phản hồi");
							else {

								try {
									st = con.createStatement();
									String ad = "select PhanHoi from nhanvien where MaNV='"
											+ txtMaSo.getText() + "'";
									st.execute(ad);
									String t = st.getResultSet().getMetaData()
											.toString();
									String sqlPhanHoi = "update nhanvien set PhanHoi='"
											+ t
											+ ""
											+ txtPhanHoi.getText().toString()
											+ "' where MaNV='"
											+ txtMaSo.getText().toString()
											+ "'";
									st.execute(sqlPhanHoi);
									JOptionPane.showMessageDialog(
											LayoutNhanVien.this,
											"Gửi phản hồi cho nhân viên "
													+ txtMaSo.getText()
													+ " thành công");
									txtPhanHoi.setEditable(false);
									btnDangKy.setEnabled(true);
									btnSua.setEnabled(true);
									btnGuiPhanHoi.setText("Gửi phản hồi");
									txtPhanHoi.setText("");
									btnHuy.setText("Xóa");
									
								} catch (SQLException e) {
									// TODO Auto-generated catch block
									e.printStackTrace();
									JOptionPane.showMessageDialog(
											LayoutNhanVien.this,
											"Gửi phản hồi không thành công");
								}

							}
						}

					} else {
						btnDangKy.setEnabled(false);
						btnSua.setEnabled(false);
						btnGuiPhanHoi.setText("Gửi");
						btnHuy.setText("Không gửi");
						btnHuy.setEnabled(true);
						txtPhanHoi.setEditable(true);

					}
				}
			});

			GroupLayout gl_panelThongtTin = new GroupLayout(panelThongtTin);
			gl_panelThongtTin
					.setHorizontalGroup(gl_panelThongtTin
							.createParallelGroup(Alignment.TRAILING)
							.addGroup(
									gl_panelThongtTin
											.createSequentialGroup()
											.addContainerGap()
											.addGroup(
													gl_panelThongtTin
															.createParallelGroup(
																	Alignment.LEADING)
															.addGroup(
																	gl_panelThongtTin
																			.createSequentialGroup()
																			.addGroup(
																					gl_panelThongtTin
																							.createParallelGroup(
																									Alignment.LEADING)
																							.addComponent(
																									lblNewLabel)
																							.addComponent(
																									lblNewLabel_1))
																			.addPreferredGap(
																					ComponentPlacement.RELATED)
																			.addGroup(
																					gl_panelThongtTin
																							.createParallelGroup(
																									Alignment.LEADING)
																							.addComponent(
																									txtHoTen,
																									GroupLayout.PREFERRED_SIZE,
																									333,
																									GroupLayout.PREFERRED_SIZE)
																							.addComponent(
																									txtMaSo,
																									GroupLayout.PREFERRED_SIZE,
																									148,
																									GroupLayout.PREFERRED_SIZE)))
															.addGroup(
																	gl_panelThongtTin
																			.createSequentialGroup()
																			.addComponent(
																					lblNewLabel_2)
																			.addPreferredGap(
																					ComponentPlacement.UNRELATED)
																			.addComponent(
																					comboGioiTinh,
																					GroupLayout.PREFERRED_SIZE,
																					100,
																					GroupLayout.PREFERRED_SIZE))
															.addGroup(
																	gl_panelThongtTin
																			.createSequentialGroup()
																			.addComponent(
																					lblNewLabel_3)
																			.addPreferredGap(
																					ComponentPlacement.RELATED)
																			.addComponent(
																					txtNgaySinh,
																					GroupLayout.PREFERRED_SIZE,
																					158,
																					GroupLayout.PREFERRED_SIZE))
															.addGroup(
																	gl_panelThongtTin
																			.createSequentialGroup()
																			.addComponent(
																					lblNewLabel_4)
																			.addGap(18)
																			.addComponent(
																					txtDiaChi,
																					GroupLayout.PREFERRED_SIZE,
																					346,
																					GroupLayout.PREFERRED_SIZE))
															.addGroup(
																	gl_panelThongtTin
																			.createSequentialGroup()
																			.addComponent(
																					lblNewLabel_5)
																			.addPreferredGap(
																					ComponentPlacement.RELATED)
																			.addComponent(
																					txtSoThueBao,
																					GroupLayout.PREFERRED_SIZE,
																					191,
																					GroupLayout.PREFERRED_SIZE))
															.addGroup(
																	gl_panelThongtTin
																			.createSequentialGroup()
																			.addComponent(
																					lblMtKhu)
																			.addPreferredGap(
																					ComponentPlacement.UNRELATED)
																			.addComponent(
																					passMatKhau,
																					GroupLayout.PREFERRED_SIZE,
																					107,
																					GroupLayout.PREFERRED_SIZE)
																			.addGap(23)
																			.addComponent(
																					lblXcNhn)
																			.addPreferredGap(
																					ComponentPlacement.RELATED)
																			.addComponent(
																					passXacNhan,
																					GroupLayout.PREFERRED_SIZE,
																					129,
																					GroupLayout.PREFERRED_SIZE))
															.addGroup(
																	gl_panelThongtTin
																			.createSequentialGroup()
																			.addComponent(
																					lblTnGiCc)
																			.addPreferredGap(
																					ComponentPlacement.UNRELATED)
																			.addComponent(
																					txtPhanHoi,
																					GroupLayout.PREFERRED_SIZE,
																					343,
																					GroupLayout.PREFERRED_SIZE)))
											.addContainerGap(90,
													Short.MAX_VALUE))
							.addGroup(
									Alignment.LEADING,
									gl_panelThongtTin
											.createSequentialGroup()
											.addGap(44)
											.addComponent(btnDangKy)
											.addPreferredGap(
													ComponentPlacement.RELATED)
											.addComponent(btnSua)
											.addPreferredGap(
													ComponentPlacement.RELATED)
											.addComponent(btnHuy)
											.addPreferredGap(
													ComponentPlacement.UNRELATED)
											.addComponent(btnGuiPhanHoi)
											.addContainerGap(78,
													Short.MAX_VALUE)));
			gl_panelThongtTin
					.setVerticalGroup(gl_panelThongtTin
							.createParallelGroup(Alignment.LEADING)
							.addGroup(
									gl_panelThongtTin
											.createSequentialGroup()
											.addContainerGap()
											.addGroup(
													gl_panelThongtTin
															.createParallelGroup(
																	Alignment.BASELINE)
															.addComponent(
																	lblNewLabel)
															.addComponent(
																	txtMaSo,
																	GroupLayout.PREFERRED_SIZE,
																	GroupLayout.DEFAULT_SIZE,
																	GroupLayout.PREFERRED_SIZE))
											.addPreferredGap(
													ComponentPlacement.RELATED)
											.addGroup(
													gl_panelThongtTin
															.createParallelGroup(
																	Alignment.BASELINE)
															.addComponent(
																	lblMtKhu)
															.addComponent(
																	passMatKhau,
																	GroupLayout.PREFERRED_SIZE,
																	GroupLayout.DEFAULT_SIZE,
																	GroupLayout.PREFERRED_SIZE)
															.addComponent(
																	passXacNhan,
																	GroupLayout.PREFERRED_SIZE,
																	GroupLayout.DEFAULT_SIZE,
																	GroupLayout.PREFERRED_SIZE)
															.addComponent(
																	lblXcNhn))
											.addPreferredGap(
													ComponentPlacement.RELATED)
											.addGroup(
													gl_panelThongtTin
															.createParallelGroup(
																	Alignment.BASELINE)
															.addComponent(
																	txtHoTen,
																	GroupLayout.PREFERRED_SIZE,
																	GroupLayout.DEFAULT_SIZE,
																	GroupLayout.PREFERRED_SIZE)
															.addComponent(
																	lblNewLabel_1))
											.addPreferredGap(
													ComponentPlacement.RELATED)
											.addGroup(
													gl_panelThongtTin
															.createParallelGroup(
																	Alignment.BASELINE)
															.addComponent(
																	lblNewLabel_2)
															.addComponent(
																	comboGioiTinh,
																	GroupLayout.PREFERRED_SIZE,
																	GroupLayout.DEFAULT_SIZE,
																	GroupLayout.PREFERRED_SIZE))
											.addPreferredGap(
													ComponentPlacement.UNRELATED)
											.addGroup(
													gl_panelThongtTin
															.createParallelGroup(
																	Alignment.BASELINE)
															.addComponent(
																	lblNewLabel_3)
															.addComponent(
																	txtNgaySinh,
																	GroupLayout.PREFERRED_SIZE,
																	GroupLayout.DEFAULT_SIZE,
																	GroupLayout.PREFERRED_SIZE))
											.addPreferredGap(
													ComponentPlacement.RELATED)
											.addGroup(
													gl_panelThongtTin
															.createParallelGroup(
																	Alignment.BASELINE)
															.addComponent(
																	lblNewLabel_4)
															.addComponent(
																	txtDiaChi,
																	GroupLayout.PREFERRED_SIZE,
																	GroupLayout.DEFAULT_SIZE,
																	GroupLayout.PREFERRED_SIZE))
											.addPreferredGap(
													ComponentPlacement.RELATED)
											.addGroup(
													gl_panelThongtTin
															.createParallelGroup(
																	Alignment.TRAILING)
															.addComponent(
																	lblNewLabel_5)
															.addComponent(
																	txtSoThueBao,
																	GroupLayout.PREFERRED_SIZE,
																	GroupLayout.DEFAULT_SIZE,
																	GroupLayout.PREFERRED_SIZE))
											.addGroup(
													gl_panelThongtTin
															.createParallelGroup(
																	Alignment.LEADING,
																	false)
															.addGroup(
																	gl_panelThongtTin
																			.createSequentialGroup()
																			.addGap(18)
																			.addComponent(
																					txtPhanHoi,
																					GroupLayout.PREFERRED_SIZE,
																					75,
																					GroupLayout.PREFERRED_SIZE)
																			.addGap(18))
															.addGroup(
																	Alignment.TRAILING,
																	gl_panelThongtTin
																			.createSequentialGroup()
																			.addPreferredGap(
																					ComponentPlacement.RELATED,
																					GroupLayout.DEFAULT_SIZE,
																					Short.MAX_VALUE)
																			.addComponent(
																					lblTnGiCc)
																			.addGap(35)))
											.addGroup(
													gl_panelThongtTin
															.createParallelGroup(
																	Alignment.BASELINE)
															.addComponent(
																	btnDangKy)
															.addComponent(
																	btnSua)
															.addComponent(
																	btnHuy)
															.addComponent(
																	btnGuiPhanHoi))
											.addGap(34)));
			panelThongtTin.setLayout(gl_panelThongtTin);

		} catch (Exception ex) {
			System.out.println(ex.toString());
			JOptionPane.showMessageDialog(this,
					"Không thể kết nối với cơ sở dữ liệu! Hãy thử lại");
			con.close();
			this.setVisible(false);
			this.setDefaultCloseOperation(EXIT_ON_CLOSE);

		}
	}

	public static void main(String[] args) throws SQLException {
		LayoutNhanVien tb = new LayoutNhanVien();
		tb.setVisible(true);
		tb.setSize(1000, 410);
		tb.setDefaultCloseOperation(EXIT_ON_CLOSE);
		tb.setResizable(false);
		tb.setTitle("Nhân viên");
	}

	public void clear() {
		txtMaSo.setText("");
		passMatKhau.setText("");
		passXacNhan.setText("");
		txtHoTen.setText("");
		txtNgaySinh.setText("");
		txtDiaChi.setText("");
		txtSoThueBao.setText("");

	}

	public void ediTrue() {
		txtMaSo.setEditable(true);
		txtHoTen.setEditable(true);
		passMatKhau.setEditable(true);
		passXacNhan.setEditable(true);
		txtNgaySinh.setEditable(true);
		txtDiaChi.setEditable(true);
		txtSoThueBao.setEditable(true);

	}

	public void ediFalse() {
		txtMaSo.setEditable(false);
		txtHoTen.setEditable(false);
		passMatKhau.setEditable(false);
		passXacNhan.setEditable(false);
		txtNgaySinh.setEditable(false);
		txtDiaChi.setEditable(false);
		txtSoThueBao.setEditable(false);

	}
}